package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.NursingProjectAndPlanDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.entity.NursingProjectAndPlan;
import com.zzyl.mapper.NursingProjectAndPlanMapper;
import com.zzyl.service.NursingPlanService;
import com.zzyl.service.NursingProjectAndPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service
public class NursingProjectAndPlanServiceImpl implements NursingProjectAndPlanService {

@Autowired
private NursingProjectAndPlanMapper npapMapper;
    @Override
    public int addList(List<NursingProjectAndPlanDto> projectPlans) {

        List<NursingProjectAndPlan> list = projectPlans.stream().map(new Function<NursingProjectAndPlanDto, NursingProjectAndPlan>() {
            @Override
            public NursingProjectAndPlan apply(NursingProjectAndPlanDto nursingProjectAndPlanDto) {
                return  BeanUtil.toBean(nursingProjectAndPlanDto,NursingProjectAndPlan.class);
            }
        }).collect(Collectors.toList());


        return npapMapper.addpj(list);
    }
}
